package pa5;

import pa5.components.OutputComponent;
import pa5.components.WrapperComponent;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.vaadin.Application;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.*;

public class MyApp extends Application {
	@Override
	public void init() {
		// Create the main window.
		Window main = new Window("My Application");
		setMainWindow(main);

		AbsoluteLayout root = new AbsoluteLayout();
		root.setHeight("900px");
		root.setWidth("1200px");
		main.setContent(root);
		//main.setSizeFull();
		root.addComponent(new OutputComponent());
		setTheme("ds-pa5theme");

		UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        if(user == null){
        	main.open(new ExternalResource(userService.createLoginURL(getURL().toString())));
        }
	}

}
